package com.cqc.zhbjcqc.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.SharedElementCallback;
import android.support.v7.app.AppCompatActivity;

import com.cqc.zhbjcqc.R;
import com.cqc.zhbjcqc.utils.SharedPreferencesUtil;

public class WelcomeActivity extends AppCompatActivity {

    private Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        context = this;

        boolean isFirst = SharedPreferencesUtil.getBoolean(context, SharedPreferencesUtil.isFirst, true);
        if (isFirst) {
            handler.sendEmptyMessageDelayed(0, 3000);
            SharedPreferencesUtil.saveBoolean(context, SharedPreferencesUtil.isFirst,false);
        } else {
            Intent intent = new Intent(context, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }


    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            Intent intent = new Intent(context, GuildActivity.class);
            startActivity(intent);
            finish();
        }
    };
}
